from api.loginApi import IhrmLogin
from common.assertTools import common_assert


class TestIhrmLogin(object):
    def setup_class(self):
        # 创建实例
        self.ihrm_login = IhrmLogin()

    def test1_login_success(self):

        req_body = {"mobile": "13800000002", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        print("登录成功",resp.json())
        common_assert(resp,200,True,10000,"操作成功")

    def test2_mobile_notregister(self):
        req_body = {"mobile": "13800000013", "password": "123456"}
        resp = self.ihrm_login.login(req_body)
        print("手机号未注册", resp.json())
        common_assert(resp,200,False,20001, "用户名或密码错误")
    def test3_pwd_err(self):  # 密码错误
        # 使用实例调用登录
        json_data = {"mobile": "13800000002", "password": "1234567"}
        resp = self.ihrm_login.login(json_data)
        print("密码错误:", resp.json())
        # 调用断言
        common_assert(resp, 200, False, 20001, "用户名或密码错误")
    def test4_10_mobile(self):  # 10位手机号
        # 使用实例调用登录
        json_data = {"mobile": "1380000000", "password": "1234567"}
        resp = self.ihrm_login.login(json_data)
        print("10位手机号:", resp.json())
        # 调用断言
        common_assert(resp, 200, False, 20001, "用户名或密码错误")
